#e
#Title[autv]
#Text[]
#Image[]
#BackGround[]
#BGM[]
#PlayLevel[Extra]
#ScriptVersion[2]
#Player[FREE]

script_enemy_main
{
let wt=20;
let usebomb=0;

	//GoɈxs镔
	@Initialize
	{
	//   eϐ

	//   XyJ[hf[^
	SetLife(800);
	SetScore(100000);
	SetDamageRate(30,  0);
	SetTimer(80);
	SetInvincibility(250);
	LoadGraphic("script\img\ExRumia.png");
	CutIn(KOUMA,"autv",GetCurrentScriptDirectory~"..\img\cutin03.png",0,0,255,320);
	}
	//   ʒu܂ňړ
	SetMovePosition02(GetCenterX, GetCenterY-100, 60);

	BG_Standard;
	AtackTaskA;
	//G̃Ct0ɂȂ܂ŁA̕1t[1s
	@MainLoop
	{
		yield;

		SetGraphicRect(0,1,63,64);
		if(GetSpeedX<0){
			SetGraphicRect(128,1,191,64);
		}
		if(GetSpeedX>0){
			SetGraphicRect(192,1,255,64);
		}

		if(OnBomb==false){
			SetCollisionA(GetX, GetY, 32);
			SetCollisionB(GetX, GetY, 24);
			usebomb=0;
		}
		else{
			usebomb++;
		}
		if(usebomb==1){
			BombBarrier;
		}
	}
	
	//`惋[vB1t[1s
	@DrawLoop
	{
		SetColor(255,255,255);
		SetAlpha(255);
		if(OnBomb==true){SetAlpha(96);}
		SetTexture("script\img\ExRumia.png");//摜͔q
		SetGraphicRect(64,1,127,64);
		DrawGraphic(GetX(),GetY());//G̍WEx[~A`;
	}
		
	//GłuԂɈxs镔
	@Finalize
	{
		SetShotColor(255,255,255);
		DeleteGraphic("script\img\ExRumia.png");
		DeleteGraphic(GetCurrentScriptDirectory ~"..img\back1.png");
		DeleteGraphic(GetCurrentScriptDirectory ~"..img\back2.png");
	}
	//XyJ[h̔wi
	//Ă悢
	@BackGround
	{
		BG_Simple;
	}

	task AtackTaskA{
		wait(120);
		let dir=0;
		let range=3;
		while(true){
			dir=GetAngleToPlayer();
			SetShotColor(96,96,96);
			loop(64){
				let spd=rand(3,16);
				CreateShotA(0,GetX,GetY,20);
				SetShotDataA(0,0,spd,dir+rand(-30,30),0,-spd/30,spd/10,WHITE01);
				FireShot(0);
			}
			SetShotColor(255,255,255);
			wait(60);
			MoveTask;
			loop(3){
				wait(40);
				SetShotColor(96,96,96);
				dir=GetAngleToPlayer();
				loop(32){
					let spd=rand(6,16);
					CreateShotA(0,GetX,GetY,20);
					SetShotDataA(0,0,spd,dir+rand(-30,30),0,-spd/30,spd/10,WHITE01);
					FireShot(0);
				}
				SetShotColor(255,255,255);
			}
			wait(60);
			MoveTask;
			wait(40);
			loop(7){
				wait(20);
				dir=GetAngleToPlayer();
				SetShotColor(96,96,96);
				loop(16){
					let spd=rand(6,16);
					CreateShotA(0,GetX,GetY,20);
					SetShotDataA(0,0,spd,dir+rand(-30,30),0,-spd/30,spd/10,WHITE01);
					FireShot(0);
				}
				SetShotColor(255,255,255);
			}
			wait(80);
			MoveTask;
			wait(40);
			
		}
	}


	task MoveTask{		//@Ɉړp^[
		let ptn=0;
		if(GetX<GetCenterX-80){ptn=1;}
		if(GetX>GetCenterX+80){ptn=2;}
		if(ptn==0){
			if(GetX<GetPlayerX){ptn=1;}
			else{ptn=2;}
		}
		if(ptn==1){
			SetMovePosition02(rand(GetX+40,GetX+60), rand(GetClipMinY+80,GetCenterY-80), 40);
		}
		if(ptn==2){
			SetMovePosition02(rand(GetX-40,GetX-60), rand(GetClipMinY+80,GetCenterY-80), 40);
		}
	}

	#include_function".\function.txt"
}

